package com.Demo;

import com.Demo.MainInterface;
import com.component.BackGroundPanel;
import com.util.ScreenUtils;

import javax.swing.*;
import java.awt.*;
import java.net.URL;

public class RegisterInterface {

    JFrame jf = new JFrame("注册");

    final int WIDTH = 650;
    final int HEIGHT = 400;

    //组装视图
    public void init() throws Exception {
        //设置窗口相关的属性
        jf.setBounds((ScreenUtils.getScreenWidth() - WIDTH) / 2, (ScreenUtils.getScreenHeight() - HEIGHT) / 2, WIDTH, HEIGHT);
        jf.setResizable(false);
        //获取图片路径并设置窗口小图标
        URL imageurl = MainInterface.class.getResource("logo.png");
        ImageIcon imageIcon = new ImageIcon(imageurl);
        Image img = imageIcon.getImage();
        jf.setIconImage(img);

        //设置窗口的内容

        URL url = MainInterface.class.getResource("Register.jpg");
        ImageIcon imageIcon1 = new ImageIcon(url);
        Image img1 = imageIcon1.getImage();
        BackGroundPanel bgPanel = new BackGroundPanel(img1);
        bgPanel.setBounds(0,0,WIDTH,HEIGHT);
        //组装登录相关的元素
        Box vBox = Box.createVerticalBox();
        //组装用户名
        Box uBox = Box.createHorizontalBox();
        JLabel uLabel = new JLabel("用户名：");
        JTextField uField = new JTextField(15);

        uBox.add(uLabel);
        uBox.add(Box.createHorizontalStrut(25));
        uBox.add(uField);

        //组装密码
        Box pBox = Box.createHorizontalBox();
        JLabel pLabel = new JLabel("密    码：");
        JTextField pField = new JTextField(15);

        pBox.add(pLabel);
        pBox.add(Box.createHorizontalStrut(25));
        pBox.add(pField);

        //组装用户类型
        Box tBox = Box.createHorizontalBox();
        JLabel tLabel = new JLabel("用户类型：");
        String[] userTypes = {"消费者", "农户", "管理员"};
        JComboBox<String> userTypeComboBox = new JComboBox<>(userTypes);
        userTypeComboBox.setAlignmentX(Component.CENTER_ALIGNMENT);

        tBox.add(tLabel);
        tBox.add(Box.createHorizontalStrut(10));
        tBox.add(userTypeComboBox);

        //组装性别
        Box gBox = Box.createHorizontalBox();
        JLabel gLabel = new JLabel("性    别：");
        JComboBox<String> regUserGenderBox = new JComboBox<>();
        regUserGenderBox.addItem("男");
        regUserGenderBox.addItem("女");

        gBox.add(gLabel);
        gBox.add(Box.createHorizontalStrut(20));
        gBox.add(regUserGenderBox);

        //组装手机号
        Box tpBox = Box.createHorizontalBox();
        JLabel tpLabel = new JLabel("手机号：");
        JTextField tpField = new JTextField(15);

        tpBox.add(tLabel);
        tpBox.add(Box.createHorizontalStrut(20));
        tpBox.add(tpField);

        //组装电子邮箱



        //组装地址



        //组装按钮
        Box btnBox = Box.createHorizontalBox();
        JButton registBtn = new JButton("注册");
        JButton backBtn = new JButton("返回登录页面");


    }
}
